// createRouter: 生成路由实例对象
// createWebHashHistory: 生成hash模式的路由配置对象

import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good/'
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      // 当二级路由patch置空 当前二级路由会作为默认显示
      {
        path: '',
        component: Home
      },
      {
        path: 'category/:id',
        component: Category
      },
      {
        path: 'good/:id',
        component: Good
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]

// 路由实例化操作
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
